/**
 * @author amalafe
 */

Namespace("sketch.ui");

(function($,ui){
	
	ui.Toolbox = function(toolBoxId, commands){
		
		//constructor
		var init = function(){
			initControls();
		};
		
		//private methods
		var initControls = function(){
			$(toolBoxId).find('.cmd').each(function(){
				var el = $(this);
				el.click(function () {
					var commandId = el.attr("data-command");
					var C = commands[commandId];
					if(C === undefined){
						throw {
							name : "Command not registered",
							description: commandId
						};
					}
                    fwk.commandManager.execute(new C(commandId, App.Current));
				});
			});
		};
		
		init.call(this);
	};

})(jQuery, sketch.ui);
